<!-- 头部公用 -->
<template>
  <div class="Blog-home">
      <div class="headBack">
        <el-row class="container">
          <el-col :span="24">
            <!-- pc端导航 -->
            <div class="headBox">
              <el-menu :default-active="activeIndex" class="el-menu-demo headerVan" mode="horizontal"  :router="true">
                <el-menu-item index="/"><i class="fa fa-wa fa-home el-icon-s-home"></i> 首页</el-menu-item>
                <el-menu-item index="/front/shouye"><i class="fa fa-shopping-basket el-icon-s-goods" aria-hidden="true"></i> 购买产品</el-menu-item>
                <el-submenu index="/music/home">
                  <template slot="title" >
                    <img style="width: 20px;" src="../../../assets/icon/音乐.png" alt="">
                    音乐秀</template>
                  <el-menu-item @click="outMusicHome"  class="titleMusic">
                    <!-- <i class="fa fa-music musicI" aria-hidden="true" style="color: red" ></i> -->
                    听听音乐</el-menu-item>
                  <el-menu-item>jay</el-menu-item>
                </el-submenu>
                <el-menu-item ><i class="fa fa-wa fa-cny"></i> 赞赏</el-menu-item>
                <el-menu-item ><i class="fa fa-wa fa-users"></i>友链</el-menu-item>

                <div class="userInfo">
                  <div v-if="!haslogin" class="nologin" style="height: 60px; margin-right: 50px ">
                    <a href="javascript:void(0);" style="font-size: 18px" @click="logoinFun(1)">登录&nbsp;</a><span  style="font-size: 18px">|</span><a  style="font-size: 18px" href="javascript:void(0);" @click="logoinFun(0)">&nbsp;注册</a>
                  </div>

                  <div class="nav-size" style="height: 60px;background-color:rgba(240,240,240,0);flex:1; ">
                    <el-menu :default-active="'1'"
                             class="el-menu-demo"
                             mode="horizontal"
                             style="background-color:rgba(240,240,240,0);border: none;display: flex;flex-wrap: nowrap; justify-content: space-between" router>
                      <el-menu-item index="/front/vip" style="border: none;background-color:rgba(240,240,240,0);position: relative;" class="daohang danghangyou">
                        <img src="../../../assets/huiyuan.png" style="left: 42%;"  alt="" srcset="">
                        <span style="">订购会员</span>
                      </el-menu-item>
                      <el-menu-item index="/front/xinxi" style="border: none;background-color:rgba(240,240,240,0);" class="daohang danghangyou">
                        <img src="../../../assets/xinxin.png"  alt="" srcset="">
                        <span>消息</span>
                      </el-menu-item>
                      <el-menu-item index="/front/dontai" style="border: none;background-color:rgba(240,240,240,0);" class="daohang danghangyou">
                        <img src="../../../assets/dontai.png"  alt="" srcset="">
                        <span>动态</span>
                      </el-menu-item>
                      <el-menu-item index="/front/shoucang" style="border: none;background-color:rgba(240,240,240,0);" class="daohang danghangyou">
                        <img src="../../../assets/choucang.png" alt="" srcset="">
                        <span>收藏</span>
                      </el-menu-item>
                      <!-- <el-menu-item index="/front/home" style="border: none;background-color:rgba(240,240,240,0);" class="tougao">
                        <img class="bubian" src="../../../assets/tougao.png"  alt="">
                        投稿
                      </el-menu-item> -->
                    </el-menu>

                  </div>
                  <div v-if="haslogin" class="haslogin" style="height: 60px; margin-right: 50px ">
                    <div style="display:flex; font-size: 12px" class="" @mouseenter="inUser" @mouseleave="outUser">
                      <el-dropdown  class="showUser">
                        <el-dropdown-menu></el-dropdown-menu>
                        <div class="userimg">
                          <div class="userimg_tu inline_block">
                            <!--  -->
                            <img :src="user.avatarUrl" alt="">
                            <transition name="el-fade-in-linear">
                              <div v-show="showUser" class="caidan">
                                <div style="height: 60px;width: 100%;"></div>
                                <div style="width:100%;height: 60px;text-align: center;line-height: 60px;"><h2 style=" font-size: 20px;font-weight: 800">{{user.nickname}}</h2></div>
                                <div style="width:100%;color: #9499a0;">
                                  <div class="inline_block pingjun bianse">文章</div>
                                  <div class="inline_block pingjun bianse">说说</div>
                                  <div class="inline_block pingjun bianse">关注</div>
                                  <div class="inline_block pingjun bianse">粉丝</div>
                                </div>
                                <div class="genr">
                                  <router-link to="/blogChangePassword" style="text-decoration: none">
                                    <span class="genren"><i class="el-icon-key"></i>修改密码</span>
                                  </router-link>
                                </div>
                                <div class="genr" @click="$router.push('/front/user')">
                                  <span style="float: left;">个人中心</span>
                                  <span style="float: right;font-weight: 100;">普通用户</span>
                                </div>
                                <div class="genr" >
                                  <span style="float: left;">金币</span>
                                  <span style="float: right;font-weight: 100;">0 <span>币</span></span>
                                </div>
                                <div class="genr" >
                                  <span style="float: left;">订购会员</span>
                                </div>
                                <div class="genr" >
                                  <span style="float: left;">我的购买</span>
                                </div>
                                <div class="genr">
                                  <span class="genren" style="text-decoration: none" @click="userlogout">退出</span>
                                </div>
                              </div>
                            </transition>

                          </div>
                        </div>
                      </el-dropdown>
                    </div>
                  </div>

                </div>
              </el-menu>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="headImgBox" >
        <div class="bg">
          <globe/>
        </div>

        <div class="scene">
          <div><span id="luke"></span></div>
        </div>
        <div class="h-information">
					<div class="icon-box" v-for="box in boxList" :key="box.id" @click="toTop(box.id)">
						<img style="width: 32px;" :src="box.img" alt="">
			
						<div class="span-box">
							<span class="span-size1" style="font-weight: bolder;">
							{{ box.title }}
							</span>
							<span style="font-size: 12px !important;">{{ box.size }}</span>
						</div>
					</div>
        </div>
      </div>

  </div>
</template>
<script>
import Rings from '@/common/bg/rings.vue';
import {
	Typeit
} from '../utils/plug.js'
import Globe from '@/common/bg/globe.vue';
// img
import AiIcon1 from '@/assets/AI-icon/视频面试.png'
import AiIcon2 from '@/assets/AI-icon/AI-icon1.png'
import AiIcon3 from '@/assets/AI-icon/AI绘画生成器.png'
import AiIcon4 from '@/assets/AI-icon/ChatGPT-icon.png'


export default {
	data() { //选项 / 数据
		return {
			userInfo: '', //用户信息
			haslogin: false, //是否已登录
			classListObj: '', //分类
			activeIndex: '/', //当前选择的路由模块
			state: '', //icon点击状态
			pMenu: true, //手机端菜单打开
			// path:'',//当前打开页面的路径
			input: '', //input输入内容
			headTou: '', //头像
			projectList: '' ,//项目列表
      user: localStorage.getItem("user")!=null ? JSON.parse(localStorage.getItem("user")):{},
      showUser: false,
			boxList:[
			{
					id:1,
					img:AiIcon4,
					title:"ChatGPT",
					size:"根据提问给予有用和有效的答案"
				},
				{
					id:2,
					img:AiIcon3,
					title:"AI绘画",
					size:"利用AI技术进行绘画"
				},
				{
					id:3,
					img:AiIcon2,
					title:"AI虚拟数字人",
					size:"提供更加个性化、有趣的交互体验"
				},
				{
					id:4,
					img:AiIcon1,
					title:"AI模拟面试",
					size:"提供针对性评估和指导"
				},
			]
    }
	},

	methods: { 
		toTop(id){
      switch (id) {
          case 1:
          console.log('跳转至chatGpt');
            let path= this.$router.resolve({
              path: '/chat'
            });
            // 打开一个新的页面
            window.open(path.href, '_blank')
          break;
					case 2:
          console.log('跳转至chatGpt');
            let pathAI= this.$router.resolve({
              path: '/chat'
            });
            // 打开一个新的页面
            window.open(pathAI.href, '_blank')
          break;
          case 3:
          console.log('跳转至信息');
            let pathinfo= this.$router.resolve({
              path: '/chat'
            });
            // 打开一个新的页面
            window.open(pathinfo.href, '_blank')
          break;
          // case 4:
          // console.log('跳转至好友');
          //   let pathuser= this.$router.resolve({
          //     path: '/chat'
          //   });
          //   // 打开一个新的页面
          //   window.open(pathuser.href, '_blank')
          // break;
      }
    },
		
		
		
		//事件处理器
		logoinFun: function(msg) { //用户登录和注册跳转
			// console.log(msg);
			// console.log(666,this.$router.currentRoute.fullPath);
			if (msg == 1) {
				this.$router.push('/NewLogin');
			} else {
				this.$router.push('/NewLogin');
			}
		},
		// 用户退出登录
		userlogout: function() {
			var that = this;
			this.$confirm('是否确认退出?', '退出提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				// console.log(that.$route.path);

        this.$store.commit("logoutOn")
        this.$message.info("退出成功")
						that.$message({
							type: 'success',
							message: '退出成功!'
						});
			}).catch(() => {
				//
			});

		},
		routeChange: function() {
			var that = this;
			that.pMenu = true

			//获取分类

		},
    getUser(){
      this.request.get("/user/"+this.user.id).then(res=>{
        console.log("Manage"+res.data)
        this.user = res.data
      })
    },
    outMusicHome(){
      let routeUrl = this.$router.resolve({
        path: "/music/home",
      });
      window.open(routeUrl.href, '_blank');
    },
    //鼠标悬停头像
    inUser(){
      this.showUser =true
    },
    //鼠标移出
    outUser(){
      this.showUser =false
    }
	},
	components: {
    Rings,
    Globe //定义组件

	},
	watch: {
		// 如果路由有变化，会再次执行该方法
		'$route': 'routeChange'
	},
	created() { //生命周期函数
		//判断当前页面是否被隐藏
		if(this.user != null){
		  this.haslogin=true
      // if(this.user.email === null || this.user.address == null|| this.user.avatarUrl == null){
      //   this.$notify({
      //     title: '个人中心',
      //     message: '尊敬的用户您的个人信息尚未完善请移动到个人中心完善个人信息',
      //     offset: 100,
      //     type: 'warning',
      //     duration: 0
      //   });
      // }
    }
		this.routeChange();

	},
	mounted() { //页面元素加载完成
		var that = this;
    var nickname= ""
		if(that.user){
      nickname = this.user.nickname
    }else {
      nickname = "请先登录"
    }
		var timer = setTimeout(function() {
			Typeit(that.$store.state.themeObj.user_start, "#luke",nickname); //打字机效果
			clearTimeout(timer);
		}, 600);
	}
}
</script>

<style lang="less" scoped>
.headBox{
	font-family: hunsize;

	// span{
	// 	font-family: hunsize;
	// }
}
@font-face {
	font-family: hunsize;
	src: url(../../../assets/size/字小魂梦幻体\(商用需授权\).ttf);
}
.headerVan{
  font-size: 50px;
}
/*********头部导航栏********/

/*头部导航栏盒子*/

.headBack {
	width: 100%;
	background: rgba(2, 2, 2, 0.6);
	/*margin-bottom:30px;*/
	box-shadow: 0 2px 4px 0 rgba(255, 255, 255, 0.12), 0 0 6px 0 rgba(255, 255, 255, 0.04);
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	z-index: 9999;
}

.headBox li.is-active {
	/*background: #48456C;*/
	background: rgba(73, 69, 107, 0.7);
}

.el-menu--horizontal>.el-submenu.is-active .el-submenu__title {
	border-bottom: none!important;
}

.headBox .el-menu {
	background: transparent;
	border-bottom: none!important;
}

.headBox .el-menu-demo li.el-menu-item,
.headBox .el-menu--horizontal .el-submenu .el-submenu__title {
  font-size: 15px;
	height: 60px;
	line-height: 60px;
	border-bottom: none!important;

}


.headBox .el-submenu li.el-menu-item {
  font-size: 15px;
	height: 60px;
	line-height: 60px;
}

.headBox li .fa-wa {
	vertical-align: baseline;
}

.headBox ul li.el-menu-item,
.headBox ul li.el-menu-item.is-active,
// .headBox ul li.el-menu-item:hover,
.headBox .el-submenu div.el-submenu__title,
.headBox .el-submenu__title i.el-submenu__icon-arrow {
  font-size: 15px;
	color: #fff;
}

.headBox .el-menu--horizontal .el-submenu>.el-menu {
	top: 60px;
	border: none;
	padding: 0;
}

.headBox>ul li.el-menu-item:hover,
.headBox>ul li.el-submenu:hover .el-submenu__title {
	border-bottom: none;
}

.headBox>ul .el-submenu .el-menu,
.headBox>ul .el-submenu .el-menu .el-menu-item {
	background: #48456C;
}

.headBox>ul .el-submenu .el-menu .el-menu-item {
  background: red;
	min-width: 0;
}

.headBox>ul .el-submenu .el-menu .el-menu-item:hover {
  background: red;
	/*background: #64609E;*/
}

/*pc搜索框*/

.headBox .pcsearchbox {
	padding: 0;
	max-width: 170px;
	/*min-width: 30px;*/
	height: 100%;
	line-height: 60px;
	position: absolute;
	top: 0;
	right: 0;
	cursor: pointer;
}

.headBox .pcsearchbox:hover .pcsearchinput {
	opacity: 1;
	/*transform: scaleX(1);*/
	visibility: visible;
}

.headBox .pcsearchbox i.pcsearchicon {
	color: #fff;
	padding-left: 10px;
}

.headBox .pcsearchbox .pcsearchinput {
	width: 180px;
	padding: 10px 20px 10px 20px;
	background: rgba(40, 42, 44, 0.6);
	border-radius: 0 0 2px 2px;
	position: absolute;
	right: 0;
	top: 60px;
	opacity: 0;
	visibility: hidden;
	/*transform: scaleX(0);*/
	transform-origin: right;
	transition: all 0.3s ease-out;
}

.headBox .pcsearchbox .hasSearched {
	opacity: 1;
	/*transform: scaleX(1);*/
	visibility: visible;
}

.headBox .pcsearchbox .el-input {
	width: 100%;
}

.headBox .el-input__inner {
	height: 30px;
	border: none;
	background: #fff;
	/*border: 1px solid #333;*/
	border-radius: 2px;
	padding-right: 10px;
}

.headBox .userInfo {
	width: 500px;
	height: 100%;
	line-height: 60px;
	position: absolute;
	right: 30px;
	top: 0;
	color: #fff;
}

.headBox .userInfo a {
	color: #fff;
	font-size: 13px;
	transition: all 0.2s ease-out;
}

.headBox .userInfo a:hover {
	color: #48456C;
}

.headBox .nologin {
	text-align: right;
  display: flex;
  justify-content: center;
  align-items: center;
}

.headBox .haslogin {
	cursor: pointer;
}

.headBox .haslogin:hover ul {
	visibility: visible;
	opacity: 1;
}

.headBox .haslogin ul {
	background: rgba(40, 42, 44, 0.6);
	padding: 5px 10px;
	position: absolute;
	right: 0;
	visibility: hidden;
	opacity: 0;
	transition: all 0.3s ease-out;
}

.headBox .haslogin ul li {
	border-bottom: 1px solid #48456C;
}

.headBox .haslogin ul li:last-child {
	border-bottom: 1px solid transparent;
}

/*******移动端*******/

.mobileBox {
	position: relative;
	height: 60px;
	line-height: 60px;
	color: #fff;
}

.hideMenu {
	position: relative;
	width: 100%;
	height: 100%;
	line-height: 60px;
}

.hideMenu ul.mlistmenu {
	width: 100%;
	position: absolute;
	left: 0;
	top: 100%;
	box-sizing: border-box;
	z-index: 999;
	box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .12), 0 0 8px 0 rgba(0, 0, 0, .04);
	background: #48456C;
	color: #fff;
	border-right: none;
}

.hideMenu .el-submenu .el-menu {
	background: #64609E;
}

.hideMenu .el-menu-item,
.hideMenu .el-submenu__title {
	color: #fff;
}

.hideMenu>i {
	position: absolute;
	left: 10px;
	top: 12px;
	width: 30px;
	height: 30px;
	font-size: 16px;
	color: #fff;
	cursor: pointer;
}

.hideMenu .el-menu-item,
.el-submenu__title {
	height: 40px;
	line-height: 40px;
}

.mobileBox .searchBox {
	padding-left: 40px;
	width: 100%;
	box-sizing: border-box;
}

.mobileBox .searchBox .el-input__inner {
	display: block;
	border-radius: 2px;
	border: none;
	height: 25px;
}

.hideMenu ul.mlistmenu.pshow {
	display: block;
}

.hideMenu ul.mlistmenu .el-submenu__icon-arrow,
.mobileBox li.el-menu-item a {
	color: #fff;
}

.hideMenu>ul li.el-menu-item:hover,
.hideMenu>ul li.el-menu-item.is-active {
	background: #48576a;
}



/*头部背景图*/

.headImgBox {
	height: 450px;
	position: relative;
	width: 100%;
	background-size: cover;
	background-position: center 60%;
	background-repeat: no-repeat;
	margin-bottom: 90px;
  background-image: url(../../../assets/static/img/jojobg.jpg);

	.bg{
		width: 100%;
		height: 450px;
		position: absolute;

	}
}

.h-information {
	text-align: center;
	width: 70%;
	height: 200px;
	margin: auto;
	position: relative;
	top: 350px;
	// padding: 0px 0;
	font-size: 16px;
	opacity: 0.98;
	// background: rgba(230, 244, 249, 0.8);
	border-radius: 5px;
	z-index: 1;
	animation: b 1s ease-out;
	-webkit-animation: b 1s ease-out;
	display: flex;
	justify-content: space-around;
	align-items: center;
	.icon-box{
		width: 20%;
		height: 40%;
		background-color: #f8f9fb;
		display: flex;
		justify-content: space-around;
		align-items: center;
		transition: all 0.2s linear;
		box-shadow: 5px 5px 10px 1px #e6e6e6;
		border-radius:5px ;
			.span-box{
				height: 80%;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				align-items: center;
				cursor:pointer;
		}
	}
	.icon-box:hover{
		transform: scale(1.1);
		transition: all 0.2s linear;
		.span-size1{
			color: #007aff;
		}
	}
}

// @-webkit-keyframes b {
// 	0% {
// 		-webkit-transform: translateY(90px);
// 		transform: translateY(90px);
// 	}
// 	80% {
// 		-webkit-transform: translateY(5px);
// 		transform: translateY(5px)
// 	}
// 	90% {
// 		-webkit-transform: translateY(-5px);
// 		transform: translateY(-5px)
// 	}
// 	to {
// 		-webkit-transform: translateY(0);
// 		transform: translateY(0)
// 	}
// }

// @keyframes b {
// 	0% {
// 		-webkit-transform: translateY(90px);
// 		transform: translateY(90px);
// 	}
// 	80% {
// 		-webkit-transform: translateY(5px);
// 		transform: translateY(5px)
// 	}
// 	90% {
// 		-webkit-transform: translateY(-5px);
// 		transform: translateY(-5px)
// 	}
// 	to {
// 		-webkit-transform: translateY(0);
// 		transform: translateY(0)
// 	}
// }

// .h-information img {
// 	width: 100px;
// 	height: 100px;
// 	border-radius: 100%;
// 	transition: all .4s ease-in-out;
// 	-webkit-transition: all .4s ease-in-out;
// 	object-fit: cover;
// }

// .h-information .img-tx:hover {
// 	transform: rotate(360deg);
// 	-webkit-transform: rotate(360deg);
// }

// .h-information h2 {
// 	margin-top: 20px;
// 	font-size: 18px;
// 	font-weight: 700;
// 	/*font-family: 'Sigmar One';*/
// }
// .h-information h2  a{
// 	background: linear-gradient(to right, #DF2060, #48456D);
// 	-webkit-background-clip: text;
// 	color: transparent;
// }
.headImgBox .scene {
	width: 100%;
	/*height:300px;*/
	text-align: center;
	font-size: 100px;
	font-weight: 200;
	color: #fff;
	position: absolute;
	left: 0;
	top: 160px;
	font-family: 'Sigmar One', Arial;
	text-shadow: 0 2px 2px #47456d;

}

.headImgBox .scene span {
	transform: matrix(1, 0, 0, 1, 0, 0);
	-webkit-transform: matrix(1, 0, 0, 1, 0, 0);
	text-shadow: 1px 1px 0 #ff3f1a, -1px -1px 0 #00a7e0;
}

.saying:after {
	content: "|";
	font-family: Arial, sans-serif;
	font-size: 1em;
	/*line-height: 0;*/
	display: inline-block;
	vertical-align: baseline;
	opacity: 1;
	text-shadow: 1px 1px 0 #ff3f1a, -1px -1px 0 #00a7e0;
	animation: caret 600ms infinite;
}

@keyframes caret {
	0%,
	100% {
		opacity: 1;
	}
	60% {
		opacity: 0;
	}
}
.musicI{
  margin-right: 10px;
  color: red;
}

/*头像*/
.showUser{
  width: 80px;
  height: 60px;
  cursor: pointer;
  .userimg {
    display: inline-block;
    width: 80px;
    height: 60px;
    position: relative;
    .userimg_tu {
      width: 80px;
      height: 60px;
      img{

        background-size: contain;
        width: 60px;
        height: 60px;
        border-radius: 60%;
        border: 3px solid white;
        position: relative;
        z-index: 2153;
        transition-property: width height;
        transition-duration: 0.3s;
      }

      .caidan{
        position:absolute;
        width: 260px;
        height: 510px;
        top: 60px;
        opacity: 0;
        left: -74px;
        z-index: 2000;
        border-radius: 15px 15px 15px 15px;
        background-color: white ;
        box-shadow:5px 5px 15px #999;
        transition-duration: 0.4s;
        transition-delay: 0.1s;
      }
    }
    .userimg_tu:hover img{
      margin-right: 50px;
      width: 110px;
      height: 110px;
    }
    .userimg_tu:hover .caidan{
      top: 60px;
      opacity: 1;
    }
  }
}
.inline_block{
  display: inline-block;
}
.pingjun{
  width:125px;
  text-align: center;
}
.bianse:hover{
  color: #00aeec;
}
.genr{
  margin: 0 auto;
  margin-top: 3px;
  width: 200px;
  height: 40px;
  line-height: 40px;
  border-radius: 8px;
  text-align: center;
  .genren{
    color: #61666D;
  }
}
.genr:hover{
  background-color: #E3E5E7;
}

/deep/ .daohang{
  font-size: 20px !important;
  height: 90px;
  line-height: 90px;
  border: none;
}

.userInfo{
  display: flex;
  justify-content: space-between;
  width: 25%;
}
.danghangyou{
  padding-top: 10px;
  position: relative;
  display: flex;
  flex-direction:column;
  justify-content: flex-end;
  align-items: center;

  img{
    width: 20px;
    height: 20px;
  }
  span{
    font-size: 15px;
    text-align: center;
    height: 50%;
    line-height: 30px;
    color: white;
    position: relative;
  }
}


// .tougao{
//   height: 20px;
//   line-height: 20px;
//   padding: 0;
//   border-radius: 5px;
//   background-color:#7dbafe !important;
//   .bubian{
//     position: none;
//     height: 15px;
//     margin-right: 5px;
//   }
// }


</style>
